<template>
  <div>
    <Film-list :list="nowList" :type="1" @myload="fnLoad"></Film-list>
  </div>
</template>

<script setup>
import FilmList from "@/components/FilmList";
import { getFilmList } from "@/api/index.js";
import { ref } from "@vue/reactivity";

let nowList = ref([]);
let num=1
let flag=ref(true)

async function getNowList(num) {
  flag.value=false
  let res = await getFilmList(num);
  nowList.value = res.data;
  flag.value=true
  console.log(nowList.value);
  if(nowList.value<10){
      flag.value=false
    }
}
getNowList(num)


//无限下拉
function fnLoad(){
  if(flag.value){
    console.log("执行",num);
    getNowList(++num)
  }
}
</script>

<style></style>
